<?php

namespace App\Models\Page;

use Eloquent as Model;
use Illuminate\Database\Eloquent\SoftDeletes;

/**
 * Class PageIcon
 * @package App\Models\Page
 * @version August 12, 2018, 9:22 am CST
 *
 * @property \App\Models\Page\PageStyle pageStyle
 * @property \App\Models\Page\Icon icon
 * @property \App\Models\Page\Icon icon
 * @property \App\Models\Page\Icon icon
 * @property integer page_style_id
 * @property string name
 * @property string areaid
 * @property integer bg
 * @property integer icon
 * @property integer cover
 * @property string opacity
 */
class PageIcon extends Model
{
    use SoftDeletes;


    public $table = 'page_icons';
    

    protected $dates = ['deleted_at'];


    public $fillable = [
        'page_style_id',
        'name',
        'areaid',
        'bg',
        'icon',
        'cover',
        'opacity'
    ];

    /**
     * The attributes that should be casted to native types.
     *
     * @var array
     */
    protected $casts = [
        'page_style_id' => 'integer',
        'name' => 'string',
        'areaid' => 'string',
        'bg' => 'integer',
        'icon' => 'integer',
        'cover' => 'integer',
        'opacity' => 'string'
    ];

    /**
     * Validation rules
     *
     * @var array
     */
    public static $rules = [
        'name' => 'required|max:100'
    ];

    /**
     * @return \Illuminate\Database\Eloquent\Relations\HasOne
     **/
    public function pageStyle()
    {
        return $this->hasOne(\App\Models\Page\PageStyle::class, 'id', 'page_style_id');
    }

    /**
     * @return \Illuminate\Database\Eloquent\Relations\HasOne
     **/
    public function bgIcon()
    {
        return $this->hasOne(\App\Models\ModelManage\Icon::class, 'id', 'bg');
    }

    /**
     * @return \Illuminate\Database\Eloquent\Relations\HasOne
     **/
    public function iconIcon()
    {
        return $this->hasOne(\App\Models\ModelManage\Icon::class, 'id', 'icon');
    }

    /**
     * @return \Illuminate\Database\Eloquent\Relations\HasOne
     **/
    public function coverIcon()
    {
        return $this->hasOne(\App\Models\ModelManage\Icon::class, 'id', 'cover');
    }
}
